// pages/find_info/index.js
var t = getApp(),
  e = t.requirejs("api/index"),
  core = t.requirejs("core"),
  wxParse = t.requirejs("wxParse/wxParse");
Page({
  data: {
    route: "find_info",
    menu: t.tabBar,
    menu_show: false,
    show: false,
    use_wxParse:true,
    list:[]
  },
  //底部导航跳转
  menu_url: function (k) {
    core.menu_url(k, 2);
  },
  onLoad: function (options) {
    console.log(111);
    console.log(options);
    var a = this;
    a.setData({
      id: options.id
    })
    if (options && options.card_id) {
      t.globalData.card_id = options.card_id;
    }
    core.setting();
    this.getinfo();
  },

  getinfo:function(){
    
    var a = this,
      id = a.data.id;
     getApp().userlog(6, '产品', 'product_browse', id);
    var e = {};
    core.get("product/product_info", {
      id: id,
    }, function (t) {
      wx.setNavigationBarTitle({
        title:  '产品详情'
        //t.info.title ? t.info.title :
      })
      if (t.code == 0) {
        try {
          wxParse.wxParse("wxParseData", "html", t.info.content, a, "0");
          e.use_wxParse = true;
          console.log("use wxParse !!!");
        }
        catch (err) {
          e.use_wxParse = false;
          console.log("not use wxParse !!!");
        }

        e.detail = t.info;
        e.show = true;
        a.setData(e)
        console.log("use_wxParse",a.data.use_wxParse)
      } else {
        core.alert(t.msg)
      }
    }, true)

  },

  onShow: function () {
    
  },
  /**
* 下拉刷新
*/
  onPullDownRefresh: function () {
    this.getinfo();
    wx.stopPullDownRefresh();
  },
  //分享
  onShareAppMessage: function () {
    var title = this.data.detail.title;
    var path = '/yb_mingpian/pages/product/info/index?id=' + this.data.detail.id + "&card_id=" + t.globalData.card_id;
    console.log(path);

    t.userlog(2, '产品', 'product_relay');

    return {
      title: title,
      path: path
    }
  },
})